package views;

import java.util.Iterator;
import java.util.List;

import models.MultipleChoiceQuestion;
import mvc.AbstractView;
import mvc.IController;

public class MultipleChoiceQView extends AbstractView
{

	public MultipleChoiceQView(IController controller, MultipleChoiceQuestion question)
	{
		super(controller);
		itsMultipleChoiceQuestion = question;
	}


	@Override
	public void onInputString(String str)
	{	
	}


	@Override
	public void update()
	{
		String s = new String();
		s = itsMultipleChoiceQuestion.getCaption();
		s += "\n";
		
		List<String> choiceList = itsMultipleChoiceQuestion.getChoiceList();
		int i = 1;
		Iterator<String> iter = choiceList.iterator();
		while(iter.hasNext())
		{
			String oneChoice = iter.next();
			s += i + ". " + oneChoice +"\n";
			++i;
		}
		
		if(itsMultipleChoiceQuestion.getItsIAnswer() != null && 
			itsMultipleChoiceQuestion.getPermission() == 0)
		{	
			// show answer
			s += "\nANSWER:\n" + itsMultipleChoiceQuestion.getItsIAnswer().getText();
		}
		System.out.println(s);	
	}
	
	private MultipleChoiceQuestion itsMultipleChoiceQuestion;
}
